package controller.client;

import util.JdbcDeal;

import javax.swing.*;
import java.sql.SQLException;

public class Client_del extends JPanel {

    public Client_del() {
        String table_Cno = JOptionPane.showInputDialog("请输入要删除客户编号）");
        String sql = "DELETE FROM client WHERE Cno = '" + table_Cno + "'";
        JdbcDeal jdbcDeal = new JdbcDeal();
        try {
            if(jdbcDeal.del(sql) == 1){
                JOptionPane.showMessageDialog(this, "成功删除一条记录！","",JOptionPane.PLAIN_MESSAGE);
                return;
            } else {
                JOptionPane.showMessageDialog(this, "删除记录失败！","", JOptionPane.WARNING_MESSAGE);
                return;
            }
        } catch (SQLException throwables) {
            JOptionPane.showMessageDialog(this, "删除记录失败！可能和其他信息有联动！请先删除相关信息！","", JOptionPane.WARNING_MESSAGE);
            throwables.printStackTrace();
        }
    }
}
